package cn.llssit.project.wechatapi.mapper;

import cn.llssit.domain.Movie;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: Lesan
 * @Date: 2020-06-27
 */
public interface WcMovieMapper {
    @Select("SELECT * FROM movie WHERE state = '正在热映' AND `show` = 1 ORDER BY box DESC,grade DESC")
    List<Movie> selectHomeCome();

    @Select("SELECT * FROM movie WHERE state = '即将上映' AND `show` = 1 ORDER BY box DESC,want DESC")
    List<Movie> selectHomeNew();

    @Select("SELECT id,name,type,grade,want,locate,duration,`describe`,date,showloc,poster,box,main_actor,state,`show`,language,(SELECT COUNT(*) AS num  FROM movie_release WHERE DATE_FORMAT(startDate,'%Y%m%d') = #{date} AND Mid = movie.id) num FROM movie WHERE state = '正在热映' ORDER BY box DESC,grade DESC")
    List<Movie> selectShowing(String date);

    @Select("SELECT * FROM movie WHERE state='即将上映' ORDER BY date")
    List<Movie> selectUpcomingdate();

    @Select("SELECT * FROM movie WHERE state='即将上映' ORDER BY date ASC, want DESC LIMIT 5")
    List<Movie> selectUpcomingLimit();
}
